package com.yq.spbYq.service.impl;

import com.yq.spbYq.User;
import com.yq.spbYq.mapper.UserMapper;
import com.yq.spbYq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    public User validateUser(String username, String password, String captcha) {
        User user = userMapper.selectByUsername(username);
        if (user != null && user.getPassword().equals(password) && user.getCaptcha().equals(captcha)) {
            return user;
        }
        return null;
    }
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }
    public int deleteUserByUsername(String username) {
        return userMapper.deleteUserByUsername(username);
    }
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }
    public List<User> selectAllUsers() {
        return userMapper.selectAllUsers();
    }
}